package com.retail.xiaocui.server.service.impl;

import java.util.List;

import com.retail.xiaocui.common.domain.req.AddPurchaseReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.retail.xiaocui.server.mapper.ProcurementMapper;
import com.retail.xiaocui.common.domain.Procurement;
import com.retail.xiaocui.server.service.ProcurementService;

/**
 * 采购需求申请Service业务层处理
 *
 * @author retail
 * @date 2024-03-02
 */
@Service
public class ProcurementServiceImpl implements ProcurementService
{
    @Autowired
    private ProcurementMapper procurementMapper;


    /**
     * 查询采购需求申请
     *
     * @param id 采购需求申请主键
     * @return 采购需求申请
     */
    @Override
    public Procurement selectProcurementById(Long id)
    {
        return procurementMapper.selectProcurementById(id);
    }

    /**
     * 查询采购需求申请列表
     *
     * @param procurement 采购需求申请
     * @return 采购需求申请
     */
    @Override
    public List<Procurement> selectProcurementList(Procurement procurement)
    {
        return procurementMapper.selectProcurementList(procurement);
    }

    /**
     * 新增采购需求申请
     *
     * @param procurement 采购需求申请
     * @return 结果
     */
    @Override
    public int insertProcurement(Procurement procurement)
    {
        procurement.setStatus(1);
        return procurementMapper.insertProcurement(procurement);
    }

    /**
     * 修改采购需求申请
     *
     * @param procurement 采购需求申请
     * @return 结果
     */
    @Override
    public int updateProcurement(Procurement procurement)
    {
        return procurementMapper.updateProcurement(procurement);
    }

    /**
     * 批量删除采购需求申请
     *
     * @param ids 需要删除的采购需求申请主键
     * @return 结果
     */
    @Override
    public int deleteProcurementByIds(Long[] ids)
    {
        return procurementMapper.deleteProcurementByIds(ids);
    }

    /**
     * 删除采购需求申请信息
     *
     * @param id 采购需求申请主键
     * @return 结果
     */
    @Override
    public int deleteProcurementById(Long id)
    {
        return procurementMapper.deleteProcurementById(id);
    }

    @Override
    public int combineProcurementByIds(Long[] ids) {
        return 0;
    }

    @Override
    public void updatePurchase(AddPurchaseReq addPurchaseReq) {
        //将状态修改成为采购中
        procurementMapper.updatePurchase(addPurchaseReq);
    }

    @Override
    public Procurement selectProId(Integer id) {
        return procurementMapper.selectProId(id);
    }
}
